Align NetworkController provider type w/ eth-query#2028
Merged
Conversation
Recent changes in `@metamask/utils` caused SafeEventEmitterProvider, the type of the provider that NetworkController exposes, to no longer align with the provider that `@metamask/eth-query` expects. We temporarily worked around this with the use of `// @ts-expect-error`, but this merely hid the problem. A fix was made in `@metamask/eth-query`, so this commit bumps that package and removes the associated `// @ts-expect-error` lines.
mcmire
commented
Nov 13, 2023
| and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
|
||
| ## [Unreleased] | ||
| ### Changed |
Contributor
Author
There was a problem hiding this comment.
I'm experimenting with adding changelogs directly to PRs. One thing I noticed is that in order to know which PR number to put here, I had to first push up this PR, then add these entries, so we'll have to note that if/when we decide to stick with this process.
MajorLift
approved these changes
Nov 14, 2023
Contributor
MajorLift
left a comment
There was a problem hiding this comment.
LGTM as follow-up from MetaMask/eth-query#21!
Contributor
|
I've made progress with removing |
This was referenced Nov 14, 2023
Merged
MajorLift
added a commit
that referenced
this pull request
Nov 15, 2023
## Explanation Fixes `// @ts-expect-error Mock eth query does not fulfill type requirements` annotations throughout core repo. ## References - Builds upon - MetaMask/eth-query#21 - #2028 - Related #1823 - Closes #2036 ## Changelog N/A ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've highlighted breaking changes using the "BREAKING" category above as appropriate
This was referenced Nov 16, 2023
MajorLift
added a commit
to MetaMask/ppom-validator
that referenced
this pull request
Feb 15, 2024
## Explanation Reduces repo-wide `any` count to 1 (excluding test files). - Types `provider` variables using the `Provider` type from `@metamask/network-controller`. - The `Provider` type is now safe to use, with its recent alignment issues resolved as of MetaMask/eth-query#21. - See also MetaMask/core#2028). - Fixes JSON-RPC typing for provider requests. - Installs `@metamask/utils` as a dependency. - Types `PPOM` variables with provisional skeleton type. - Fixes for controller-messenger typing. - Fixes for misc. `any` usage ## References - Closes #144 ## Changelog ### Changed - Add `@metamask/utils` ^8.3.0 as a dependency. ([#89](#89)) ### Removed - **BREAKING:** `NetworkControllerStateChangeEvent` is removed from the `PPOMControllerEvents` union type. ([#89](#89)) ### Fixed - **BREAKING**: `PPOMController` class constructor option types are narrowed from `any`. ([#89](#89)) - The constructor expects `provider` to be the `Provider` type from `@metamask/network-controller` (equivalent to `SafeEventEmitterProvider` from `@metamask/eth-json-rpc-provider`). - The constructor expects `onPreferencesChange` to be `(callback: (preferencesState: { securityAlertsEnabled: boolean } & Record<string, Json>) => void) => void`. - **BREAKING:** The `UsePPOM` type replaces `any` with the `PPOM` type in its definition. ([#89](#89)) - **BREAKING:** When a `PPOM` class instance makes JSON-RPC requests to the provider, the `params` type is now widened from `Record<string, unknown>` to `JsonRpcParams`, and the response type is narrowed from `any` to `JsonRpcSuccess<Json>`. ([#89](#89)) ## Commits * Linter fixes * Install `@metamask/utils` as dependency * Add entries to depcheck ignore to fix yarn depcheck error * Fix JSON RPC types for provider requests * Fix controller-messenger typing * Explicitly enumerate package-level exports from `ppom-controller` * Type `provider` variables with `SafeEventEmitterProvider` from network-controller * Type `ppom` variables with provisional skeleton type * Fix various `any` usage and typos * Add TODO for fixing `any` * Improve error response typing for `#jsonRpcRequest` * Replace null check for `oldestChainId` with non-null assertion * Replace null check for `this.#ppom` with non-null assertion * Replace unnecessary null fallback with non-null assertion * Linter fix * Record CHANGELOG * Remove changelog entries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
Recent changes in
@metamask/utilscaused SafeEventEmitterProvider, the type of the provider that NetworkController exposes, to no longer align with the provider that@metamask/eth-queryexpects. We temporarily worked around this with the use of// @ts-expect-error, but this merely hid the problem. A fix was made in@metamask/eth-query, so this commit bumps that package and removes the associated// @ts-expect-errorlines.References
Fixes #1823.
Also see: MetaMask/eth-query#21
Changelog
(See updates to changelogs in this PR.)
Checklist